package com.xjtu.platform.security.infomanage.imply;

import com.xjtu.platform.common.Utils;
import com.xjtu.platform.security.infomanage.InfoManageDto;
import com.xjtu.platform.security.infomanage.InfoManageService;
import com.xjtu.platform.security.infomanage.dao.InfoManageDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

@Service
@Transactional
public class InfoManageImply implements InfoManageService {


    @Resource
    InfoManageDao infoManageDao;

    @Override
    public boolean deleteInfo(InfoManageDto dto) {
        infoManageDao.deleteInfo(dto);


        return false;
    }

    @Override
    public void changeInfo(InfoManageDto dto) {
        infoManageDao.changeInfo(dto);
        System.out.println(dto.getEmail());
    }

    @Override
    public Map<String, Object> getInfo(InfoManageDto dto) {
        return Utils.getPage(dto,()->infoManageDao.getInfo(dto));
    }

    @Override
    public boolean insertInfo(InfoManageDto dto) {

        String count = infoManageDao.Count()+1+"role";
        dto.setUser_role_id(count);
        infoManageDao.insertInfo(dto);
        infoManageDao.insertRole(dto);
        return false;
    }
}
